﻿//
// Created by 50177 on 2019/8/6.
//

#include "include/OCTDevice/OctMirror.h"
#include <QMetaEnum>
#include <include/Communication/Request.h>
#include <include/Communication/Protocol.h>

//#include "include/Gui/BVGui_Select.h"
//#include "include/Log/QBVLog.h"

#include <QDebug>

OctMirror *OctMirror::instance = nullptr;

OctMirror *OctMirror::getInstance() {
    if (!instance) {
        instance = new OctMirror();
    }
    return instance;
}

OctMirror::OctMirror() {
}

void OctMirror::reset() {
    Protocol::getInstance()->send(Request(Request::Type::Mirror_Reset));
}

//void OctMirror::modeControl(OctMode *params) {
//    Request request(Request::Type::Mirror_Mode_Control);
//    request.setMode(params->getMode());
//    request.setMirrorDirection(params->getScanDirection());
//    request.setMirrorTrigger(params->getSignalTrigger());
//    request.setVoltage(params->getVoltage());//直流电压
//    request.setCycle(params->getCycle());
//    Protocol::getInstance()->send(request);
//}

//void OctMirror::lengthControl(OctMode *params) {//modified by qinyaning 202009071813
//    Request request(Request::Type::Mirror_Axis_Fast_Length_Control);    
//
//    LOG4CPLUS_INFO(QBVLog::Instance()->Log4cplusLogger(), "getMode: " << params->getMode() << " in OctMirror::lengthControl");
//
//    //(params->getScanDirection() == OctMode::ScanDirection::Horizontal)?
//    request.setMode(params->getMode());
//
//    LOG4CPLUS_INFO(QBVLog::Instance()->Log4cplusLogger(), "getAxisFastStart: "
//                   << params->getAxisFastStart() << " in OctMirror::lengthControl");
//
//    request.setAxisFastStart(params->getAxisFastStart());
//
//    LOG4CPLUS_INFO(QBVLog::Instance()->Log4cplusLogger(), "getAxisFastEnd: "
//                   << params->getAxisFastEnd() << " in OctMirror::lengthControl");
//
//    request.setAxisFastEnd(params->getAxisFastEnd());
//
//    if(params->getMode() == OctMode::Mode::Area
//            && params->getScanDirection() == OctMode::ScanDirection::Vertical) {
//
//        //LOG4CPLUS_INFO(QBVLog::Instance()->Log4cplusLogger(), "BVGui_Select::getInstance()->OctAreaVerModeParams()->AxisFastStart: "
//        //               << BVGui_Select::getInstance()->OctAreaVerModeParams()->AxisFastStart());
//
//        //request.setAxisFastStart(BVGui_Select::getInstance()->OctAreaVerModeParams()->AxisFastStart());
//
//        //LOG4CPLUS_INFO(QBVLog::Instance()->Log4cplusLogger(), "BVGui_Select::getInstance()->OctAreaVerModeParams()->AxisFastEnd: "
//        //               << BVGui_Select::getInstance()->OctAreaVerModeParams()->AxisFastEnd());
//
//        //request.setAxisFastEnd(BVGui_Select::getInstance()->OctAreaVerModeParams()->AxisFastEnd());
//
//        LOG4CPLUS_INFO(QBVLog::Instance()->Log4cplusLogger(), "BVGui_Select::getInstance()->OctAreaVerModeParams()->AxisFastStart: "
//            << params->getVerAxisFastStart());
//
//        request.setAxisFastStart(params->getVerAxisFastStart());
//
//        LOG4CPLUS_INFO(QBVLog::Instance()->Log4cplusLogger(), "BVGui_Select::getInstance()->OctAreaVerModeParams()->AxisFastEnd: "
//            << params->getVerAxisFastEnd());
//
//        request.setAxisFastEnd(params->getVerAxisFastEnd());
//    }
//
//    Protocol::getInstance()->send(request);
//
//    if (params->getMode() == OctMode::Mode::Area ||
//        params->getMode() == OctMode::Mode::Enface ||
//        params->getMode() == OctMode::Mode::GlaucomaDisc||
//		params->getMode() == OctMode::Mode::GlaucomaMacula) {
//        Request request(Request::Type::Mirror_Axis_Slow_Length_Control);
//        request.setMode(params->getMode());
//        request.setAxisSlowStart(params->getAxisSlowStart());
//        request.setAxisSlowEnd(params->getAxisSlowEnd());
//        if(params->getMode() == OctMode::Mode::Area
//                && params->getScanDirection() == OctMode::ScanDirection::Vertical) {
//
//            //LOG4CPLUS_INFO(QBVLog::Instance()->Log4cplusLogger(), "BVGui_Select::getInstance()->OctAreaVerModeParams()->AxisSlowStart: "
//            //               << BVGui_Select::getInstance()->OctAreaVerModeParams()->AxisSlowStart());
//
//            //request.setAxisSlowStart(BVGui_Select::getInstance()->OctAreaVerModeParams()->AxisSlowStart());
//
//            //LOG4CPLUS_INFO(QBVLog::Instance()->Log4cplusLogger(), "BVGui_Select::getInstance()->OctAreaVerModeParams()->AxisSlowEnd: "
//            //               << BVGui_Select::getInstance()->OctAreaVerModeParams()->AxisSlowEnd());
//
//            //request.setAxisSlowEnd(BVGui_Select::getInstance()->OctAreaVerModeParams()->AxisSlowEnd());
//
//            LOG4CPLUS_INFO(QBVLog::Instance()->Log4cplusLogger(), "BVGui_Select::getInstance()->OctAreaVerModeParams()->AxisSlowStart: "
//                << params->getVerAxisSlowStart());
//
//            request.setAxisSlowStart(params->getVerAxisSlowStart());
//
//            LOG4CPLUS_INFO(QBVLog::Instance()->Log4cplusLogger(), "BVGui_Select::getInstance()->OctAreaVerModeParams()->AxisSlowEnd: "
//                <<params->getVerAxisSlowEnd());
//
//            request.setAxisSlowEnd(params->getVerAxisSlowEnd());
//        }
//        Protocol::getInstance()->send(request);
//    }
//}
